#include "stdafx.h"

CWnd* getAWTWindow(CWnd* w)
{
	CWnd* wnd = w;
	CString str;
	TCHAR szClass[128];
	BOOL bFound = FALSE;
	do {
		wnd = wnd->GetParent();
		wnd->GetWindowText(str);
		::GetClassName(wnd->m_hWnd, szClass, 128);
		if (str == "!~AWTWindow~!")
		{
			bFound = TRUE;
			break;
		}
		else if (wnd->IsKindOf(RUNTIME_CLASS(AWTDialogPeer)))
		{
			bFound = TRUE;
			break;
		}
		else if (wnd->IsKindOf(RUNTIME_CLASS(AWTMdiChildWnd)))
		{
			bFound = TRUE;
			break;
		}
		else if (CString(szClass) == CString("#32770"))
		{
			bFound = TRUE;
			break;
		}
	} while (wnd != NULL);
	return wnd;
}

void Trace(LPTSTR lpsz)
{
#if 0
	FILE* out = fopen("d:\\john\\debug.txt", "a");
	if (out != NULL)
	{
		fputs(lpsz, out);
		fclose(out);
	}
#endif
}